/*
 * Unit.cc
 *
 *  Created on: Mar 9, 2011
 *      Author: topcoder
 */

#include "VolumeUnit.h"

const unsigned int RATIO_TSP_TO_BASE_UNIT = 1;
const unsigned int RATIO_TBSP_TO_BASE_UNIT = 3*RATIO_TSP_TO_BASE_UNIT;
const unsigned int RATIO_OZ_TO_BASE_UNIT = 2*RATIO_TBSP_TO_BASE_UNIT;

static VolumeUnit* oz = NULL;
static VolumeUnit* tbsp = NULL;
static VolumeUnit* tsp = NULL;

VolumeUnit::VolumeUnit(const unsigned int ratio2BaseUnit,const string name):Unit(ratio2BaseUnit,name)
{
}

VolumeUnit& VolumeUnit:: getOZ()
{
    if(oz == NULL)
    {
        oz = new VolumeUnit(RATIO_OZ_TO_BASE_UNIT, "OZ");
    }

    return *oz;
}

VolumeUnit& VolumeUnit:: getTBSP()
{
    if(tbsp == NULL)
    {
        tbsp = new VolumeUnit(RATIO_TBSP_TO_BASE_UNIT, "TBSP");
    }

    return *tbsp;
}

VolumeUnit& VolumeUnit:: getTSP()
{
    if(tsp == NULL)
    {
        tsp = new VolumeUnit(RATIO_TSP_TO_BASE_UNIT, "TSP");
    }

    return *tsp;
}
